Skip to content
This repository was archived by the owner on Nov 10, 2022. It is now read-only.

Allow ll-specific multihash #1

Merged
merged 5 commits into from
Feb 16, 2021
Merged

Conversation

liamsi
Copy link
Member

@liamsi liamsi commented Feb 2, 2021

This change is necessary if we want IPFS to allow our custom hasher that is introduced and used in celestiaorg/celestia-core#155 and celestiaorg/go-ipfs#1

Note: this PR simply duplicates a constant introduced in another repo. namely, 0x7701. It corresponds to the custom hasher code defined and registered in the LazyLedger ipld plugin. The calling code makes sure via a test, that a changing the constant only there wouldn't go unnoticed.

@liamsi liamsi force-pushed the liamsi/go-verifcid_allow_custom_mh branch from 9421478 to c3e21cf Compare February 5, 2021 23:29
 - and hack in that it accepts Sha256Namespace8Flagged = 0x7701
validate.go Outdated
Comment on lines 47 to 52
// XXX: This has to be on par with what the LazyLedger IPLD plugin registers as a multihash
// namely, Sha256Namespace8Flagged. We simply repeat the constant here instead of
// importing the corresponding package from lazyledger-core as this would be overkill.
if code == 0x7701 {
return true
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An alternative would be to import the constant from where it is defined, currently in lazyledger-core:
https://github.com/lazyledger/lazyledger-core/blob/755a7175168e57e9f1996341e533683eace5c5d3/p2p/ipld/plugin/nodes/nodes.go#L27-L29

For now it seems more reasonable to repeat this here instead of introducing a massive dependency and assert that this checks out by the consumer of verifcid:
https://github.com/lazyledger/lazyledger-core/blob/7b9550659e2bd957b4042880b8339d9e1d84c9c0/p2p/ipld/plugin/nodes/nodes_test.go#L26-L30

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to extract "common" dependency. But creating a module just for single const seems like overengineering.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thought about this too. But I agree, it would be overkill for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to make this use of a magic number a bit more...documented (can't think of a better word)? I.e. this file documents what's happening, but if you go modify the magic number the other file you have no idea this one exists. Even putting it in the PR's description instead of a comment would go a long way.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll put it in the PR description.

BTW, there is a test in the consuming code that would fail if the constant was modified without updating it here accordingly: https://github.com/lazyledger/lazyledger-core/blob/3308e7636503ded830e476cd79ec4f9a5cf16de0/p2p/ipld/plugin/nodes/nodes_test.go#L26-L30

@liamsi liamsi marked this pull request as ready for review February 13, 2021 21:22
@liamsi liamsi changed the title change to allow ll-specific codec and ll go-multihash fork Allow ll-specific multihash Feb 13, 2021
validate.go Outdated
Comment on lines 47 to 52
// XXX: This has to be on par with what the LazyLedger IPLD plugin registers as a multihash
// namely, Sha256Namespace8Flagged. We simply repeat the constant here instead of
// importing the corresponding package from lazyledger-core as this would be overkill.
if code == 0x7701 {
return true
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option is to extract "common" dependency. But creating a module just for single const seems like overengineering.

@liamsi liamsi merged commit d635594 into master Feb 16, 2021
@liamsi liamsi deleted the liamsi/go-verifcid_allow_custom_mh branch February 16, 2021 17:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants